<?php

namespace DeCMF\Core\Db;

/**
 * DB表通用状态
 */
class Status
{
    
    /**
     * 删除状态
     */
    const DELETED = -1;
    
    const FORBIDDEN = 0;
    
    /**
     * 正常  从回收站还原会直接变成正常
     */
    const NORMAL = 1;
    
    /**
     * 待审核
     */
    const UNREVIEWED = 2;
    
    protected static $statuses = [
        self::DELETED => '已删除',
        self::FORBIDDEN => '禁用',
        self::NORMAL => '正常',
        self::UNREVIEWED => '待审核'
    ];
    
    protected static $operStatuses = [
        self::FORBIDDEN => '启用',
        self::NORMAL => '禁用',
        self::UNREVIEWED => '审核',
    ];

    /**
     * 
     * @return array 所有状态
     */
    public static function all()
    {
        return static::$statuses;
    }
    
    /**
     * 获取对应状态的标签
     * @param int $status
     * @return string
     */
    public static function label($status)
    {
        return isset(static::$statuses[$status])
                ? static::$statuses[$status]
                : '-';
    }
    
    /**
     * 获取对应状态的操作标签
     * @param int $status
     * @return string
     */
    public static function operLabel($status)
    {
        return isset(static::$operStatuses[$status])
                ? static::$operStatuses[$status]
                : '-';
    }

}
